﻿using System;
using System.Collections.Generic;

namespace CloudTaobao
{
    public class Item
    {
        public string num_iid{get;set;}
        public string title{get;set;}
        public string nick{get;set;}
        public string pic_url { get; set; }
        public string cid { get; set; }
        public string price{get;set;}
        public string post_fee { get; set; }
        public string wap_detail_url { get; set; }
        public string volume { get; set; }
        public string promoted_service { get; set; }
        public string is_prepay { get; set; }
        public Location location { get; set; }
        public string type { get; set; }
        public string num { get; set; }
        public string stuff_status { get; set; }
        public string express_fee { get; set; }
        public string ems_fee { get; set; }
        public string freight_payer { get; set; }
        public string score { get; set; }
        public string wap_desc { get; set; }
        public List<Sku> skus;
        public int colwidth
        {
            get
            {
                if (pic_url == "")
                    return 456;
                else
                    return 338;
            }
        }
        public string showPic 
        {
            get 
            {
                if (pic_url == "")
                    return "Collapsed";
                else
                    return "Visible";
            }
        }
        public string isPrepay
        {
            get
            {
                if ("true".Equals(is_prepay))
                    return "Visible";
                else
                    return "Collapsed";
            }
        }
        public string oneToThree
        {
            get
            {
                if (promoted_service!=null&&promoted_service.Contains("2"))
                    return "Visible";
                else
                    return "Collapsed";
            }
        }
        public string sevenDay
        {
            get
            {
                if (promoted_service != null&&promoted_service.Contains("4"))
                    return "Visible";
                else
                    return "Collapsed";
            }
        }
        public string postPayer
        {
            get
            {
                if ("seller".Equals(freight_payer))
                    return "卖家承担运费";
                else
                    return "买家承担运费";
            }
        }
        public string showPostPayer
        {
            get
            {
                if ("seller".Equals(freight_payer))
                    return "Visible";
                else
                    return "Collapsed";
            }
        }
        public string itemState
        {
            get
            {
                if ("new".Equals(stuff_status))
                    return "全新";
                else if ("unused".Equals(stuff_status))
                    return "闲置";
                else if ("second".Equals(stuff_status))
                    return "二手";
                else
                    return "未知";
            }
        }
        public string sellerScoreUri
        {
            get
            {
                if (score == "")
                    return "";
                int lv = Convert.ToInt32(score);
                switch (lv)
                {
                    case 1:
                        return "icons/red1.png";
                    case 2:
                        return "icons/red2.png";
                    case 3:
                        return "icons/red3.png";
                    case 4:
                        return "icons/red4.png";
                    case 5:
                        return "icons/red5.png";
                    case 6:
                        return "icons/zuan1.png";
                    case 7:
                        return "icons/zuan2.png";
                    case 8:
                        return "icons/zuan3.png";
                    case 9:
                        return "icons/zuan4.png";
                    case 10:
                        return "icons/zuan5.png";
                    case 11:
                        return "icons/king1.png";
                    case 12:
                        return "icons/king2.png";
                    case 13:
                        return "icons/king3.png";
                    case 14:
                        return "icons/king4.png";
                    case 15:
                        return "icons/king5.png";
                    case 16:
                        return "icons/gold1.png";
                    case 17:
                        return "icons/gold2.png";
                    case 18:
                        return "icons/gold3.png";
                    case 19:
                        return "icons/gold4.png";
                    case 20:
                        return "icons/gold5.png";
                    default:
                        return "";
                }
            }
        }

        public Item()
        {
            num_iid = "";
            title = "";
            nick = "";
            pic_url = "";
            cid = "";
            price = "";
            post_fee = "";
            wap_detail_url = "";
            volume = "";
            promoted_service = "";
            location = new Location();
            type = "";
            num = "";
            stuff_status = "";
            express_fee = "";
            ems_fee = "";
            freight_payer = "";
            skus = new List<Sku>();
            wap_desc = "";
        }
    }
    public class Sku
    {
        public string sku_id { get; set; }
        public string properties { get; set; }
        public string quantity { get; set; }

        public Sku() 
        {
            sku_id = "";
            properties = "";
            quantity = "";
        }
    }
}
